package ValidListDemo;

import com.tsing.cli.common.valid.AddGroup;
import com.tsing.cli.common.valid.UpdateGroup;
import com.tsing.cli.common.valid.ValidList;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import lombok.Data;

@Data
public class OrderReqVO {

    @Null(message = "新增时不能传入id", groups = {AddGroup.class})
    @NotBlank(message = "id不能为空", groups = {UpdateGroup.class})
    private String id;

    @Valid
    @NotEmpty(message = "至少包含一个订单清单", groups = {AddGroup.class, UpdateGroup.class})
    private ValidList<OrderDetailReqVO> orderDetails;

    @Data
    public static class OrderDetailReqVO {

        @NotBlank(message = "货物id不能为空", groups = {AddGroup.class, UpdateGroup.class})
        private String goodsId;

        @NotNull(message = "数量不能为空", groups = {AddGroup.class, UpdateGroup.class})
        @DecimalMin(value = "1", message = "数量不能小于1", groups = {AddGroup.class, UpdateGroup.class})
        private Integer amount;

    }

}
